System Settings 本文未发布 发布文章

未匹配的标注

At many cases you need to have some dynamic system settings, such as in a referral program, where you give ‘gifts’ to anyone who refers new users. But those gifts can be changed in the future, so it’s better not have them statically created in the code, instead read from the database where an Admin can manage them at any time.
The app/Containers/Settings Container helps storing and retrieving those key values settings. It also seed the database with the default configurations during the installation.

Seed the default settings

Default Settings should be seeded in app/Containers/Settings/Database/Seeders/DefaultSystemSettingsSeeder.php

Read settings

<?php
$value = $this->findSettingsByKeyTask->run('whateverSettingsName');

You can search for settings by Key as in the example above, or create a class for each settings as follow:

<?php
$value = $this->findWhateverSettingsTask->run();

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~